<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <a href="http://baidu.com">百度</a>
    <a href="#/home">home</a>
    <a href="#/set">set</a>
    <div id="box"></div>
    <script>
        console.log(location.hash);
        let box = document.querySelector('#box');
        window.onhashchange = function(){
            let hash = location.hash;
            if(hash === '#/home'){
                box.innerHTML = 'home';
            }else if(hash === '#/set'){
                box.innerHTML = 'set';
            }
        }
    </script>
</body>
</html>